-
Notifications
You must be signed in to change notification settings - Fork 669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix paddleOCR size issue #775
Conversation
return new int[] {h32 * 32, w32 * 32}; | ||
int w32 = Math.max((int) w / 32 / h32, 1); | ||
// height must be 32 (fixed) | ||
return new int[] {32, w32 * 32}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if height is fixed to 32, shouldn't the algorithm be just w = 32 / h * w ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still need to make sure width are base 32 number and has proper aspect ratio
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this work:
int ratio = Math.floorDiv(w, h);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this doesn't apply here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
floorDiv cannot be used on floating number
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As Jake pointed out, if you height is always 32, the width should simply be 32 * ratio,
no need to test if size is less then 32 or not. the whole function can be:
int ratio = Math.max((int) w / h, 1);
return new int[] {32, 32 * ratio};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried this way, the last inference result is always wrong. Will try this implementAction again.
int w32 = (int) w / 32; | ||
return new int[] {h32 * 32, w32 * 32}; | ||
private int[] resize32(double w) { | ||
int width = ((int) Math.max(32, w)) / 32 * 32; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not correct. This basically keep the original width and removed the remainder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it trimmed the width to a 32 based number. The apect ratio didn't help on the inference result
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is weird, Can you add a comments here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
Description
The word recognition OCR model from PaddlePaddle require height to be fixed 32 or an error will be thrown.